import React from "react";
import { connect } from "./connect";

function ReduxTest({ counter, handleAdd }) {
  return (
    <div>
      {counter.count}
      <button onClick={handleAdd}>按钮</button>
    </div>
  );
}

const mapStateToProps = (state) => {
  return {
    counter: state.counter,
  };
};

const mapDispatchToProps = (dispatch) => {
  return {
    handleAdd: () => {
      dispatch({ type: "ADD_COUNT" });
    },
  };
};

export default connect(mapStateToProps, mapDispatchToProps)(ReduxTest);
